<%@ Page Language="C#" ValidateRequest="false" AutoEventWireup="true" CodeFile="edit_bug.aspx.cs" Inherits="edit_bug" %>
<!--
Copyright 2002-2011 Corey Trager
Distributed under the terms of the GNU General Public License
-->
<!-- #include file = "inc.aspx" -->
<html>
<head>
    <title id="titl" runat="server">add new</title>
    <link rel="StyleSheet" href="btnet.css" type="text/css">
    <link rel="StyleSheet" href="jquery/jquery-ui-1.7.2.custom.css" type="text/css">
    <!-- use btnet_edit_bug.css to control positioning on edit_bug.asp.  use btnet_search.css to control position on search.aspx  -->
    <link rel="StyleSheet" href="custom/btnet_edit_bug.css" type="text/css">
    <script type="text/javascript" language="JavaScript" src="jquery/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" language="JavaScript" src="jquery/jquery-ui-1.7.2.custom.min.js"></script>
    <script type="text/javascript" language="JavaScript" src="jquery/jquery.textarearesizer.compressed.js"></script>
    <script type="text/javascript" language="JavaScript" src="edit_bug.js"></script>
    <%  if (security.user.use_fckeditor)
        { %>
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    <% } %>
    <script>
var this_bugid = <% Response.Write(Convert.ToString(id)); %>

$(document).ready(do_doc_ready);

function do_doc_ready()
{
	date_format = '<% Response.Write(btnet.Util.get_setting("DatepickerDateFormat","yy-mm-dd")); %>'
	$(".date").datepicker({dateFormat: date_format, duration: 'fast'})
	$(".date").change(mark_dirty)
	$(".warn").click(warn_if_dirty) 
	$("textarea.resizable:not(.processed)").TextAreaResizer()
	
	<% 
	
	if (security.user.use_fckeditor)	
	{
		Response.Write ("CKEDITOR.replace( 'comment' )");
	}
	else
	{
		Response.Write("$('textarea.resizable2:not(.processed)').TextAreaResizer()");
	}	
	
	%>	
}

function disable_second_button()
{
<% if (btnet.Util.get_setting("DisplayAnotherButtonInEditBugPage","0") == "1") { %>
	el = get_el("sub");
	el.disabled = true;
<% } %>	
}

    </script>
</head>
<body onload='on_body_load()' onunload='on_body_unload()'>
    <% security.write_menu(Response, btnet.Util.get_setting("PluralBugLabel", "bugs")); %>
    <div class="align">
        <% if (!security.user.adds_not_allowed && id > 0)
           { %>
        <a class="warn" href="edit_bug.aspx?id=0">
            <img src="add.png" border="0" align="top">&nbsp;add new
            <asp:Label ID="singular_bug_label" runat="server"></asp:Label></a>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <% } %>
        <span id="prev_next" runat="server">&nbsp;</span>
        <br>
        <br>
        <table border="0" cellspacing="0" cellpadding="3">
            <tr>
                <td nowrap valign="top">
                    <!-- links -->
                    <div id="edit_bug_menu">
                        <ul>
                            <li id="clone" runat="server" />
                            <li id="print" runat="server" />
                            <li id="merge_bug" runat="server" />
                            <li id="delete_bug" runat="server" />
                            <li id="svn_revisions" runat="server" />
                            <li id="git_commits" runat="server" />
                            <li id="hg_revisions" runat="server" />
                            <li id="subscribers" runat="server" />
                            <li id="subscriptions" runat="server" />
                            <li id="relationships" runat="server" />
                            <li id="tasks" runat="server" />
                            <li id="send_email" runat="server" />
                            <li id="attachment" runat="server" />
                            <li id="custom" runat="server" />
                        </ul>
                    </div>
                    <td nowrap valign="top">
                        <!-- form -->
                        <div id="bugform_div">
                            <form class="frm" runat="server">
                            <% if (btnet.Util.get_setting("DisplayAnotherButtonInEditBugPage", "0") == "1")
                               { %>
                            <div>
                                <span runat="server" class="err" id="custom_field_msg2">&nbsp;</span> <span runat="server"
                                    class="err" id="msg2">&nbsp;</span>
                            </div>
                            <div style="text-align: center;">
                                <input runat="server" class="btn" type="submit" id="sub2" onclick="disable_me()"
                                    value="Update" onserverclick="on_update">
                            </div>
                            <% } %>
                            <table border="0" cellpadding="3" cellspacing="0">
                                <tr>
                                    <td nowrap valign="top">
                                        <span class="lbl" id="bugid_label" runat="server"></span><span runat="server" class="bugid"
                                            id="bugid"></span>&nbsp;
                                        <td valign="top">
                                            <span class="short_desc_static" id="static_short_desc" runat="server" style='width: 500px;
                                                display: none;'></span>
                                            <input title="" runat="server" type="text" class="short_desc_input" id="short_desc"
                                                maxlength="200" onkeydown="count_chars('short_desc',200)" onkeyup="count_chars('short_desc',200)">
                                            &nbsp;&nbsp;&nbsp; <span runat="server" class="err" id="short_desc_err"></span>
                                            <div class="smallnote" id="short_desc_cnt">
                                                &nbsp;</div>
                            </table>
                            <table width="90%" border="0" cellpadding="3" cellspacing="0">
                                <tr>
                                    <td nowrap>
                                        <span runat="server" id="reported_by"></span>
                                        <% if (id == 0 || permission_level == Security.PERMISSION_ALL)
                                           { %>
                                        <td nowrap align="right" id="presets">
                                            Presets: <a title="Use previously saved settings for project, category, priority, etc..."
                                                href="javascript:get_presets()">use</a> &nbsp;/&nbsp; <a title="Save current settings for project, category, priority, etc., so that you can reuse later."
                                                    href="javascript:set_presets()">save</a>
                                            <% } %>
                            </table>
                            <table border="0" cellpadding="0" cellspacing="4">
                                <tr id="tags_row">
                                    <td nowrap>
                                        <span class="lbl" id="tags_label" runat="server">Tags:&nbsp;</span>
                                        <td nowrap>
                                            <span class="stat" id="static_tags" runat="server"></span>
                                            <input runat="server" type="text" class="txt" id="tags" size="70" maxlength="80"
                                                onkeydown="mark_dirty()" onkeyup="mark_dirty()">
                                            <span id="tags_link" runat="server">&nbsp;&nbsp;<a href='javascript:show_tags()'>tags</a></span>
                                            <tr id="row1">
                                                <td nowrap>
                                                    <span class="lbl" id="project_label" runat="server">Project:&nbsp;</span>
                                                    <td nowrap>
                                                        <span class="stat" id="static_project" runat="server"></span>
                                                        <asp:DropDownList ID="project" runat="server" AutoPostBack="True">
                                                        </asp:DropDownList>
                                                        <!--
		<td rowspan=100 bgcolor=yellow width=40>&nbsp;
		<td rowspan=100 bgcolor=pink width=200>I'll put something here eventually...
		-->
                                                        <tr id="row2">
                                                            <td nowrap>
                                                                <span class="lbl" id="org_label" runat="server">Organization:&nbsp;</span>
                                                                <td nowrap>
                                                                    <span class="stat" id="static_org" runat="server"></span>
                                                                    <asp:DropDownList ID="org" runat="server">
                                                                    </asp:DropDownList>
                                                                    <tr id="row3">
                                                                        <td nowrap>
                                                                            <span class="lbl" id="category_label" runat="server">Category:&nbsp;</span>
                                                                            <td nowrap>
                                                                                <span class="stat" id="static_category" runat="server"></span>
                                                                                <asp:DropDownList ID="category" runat="server">
                                                                                </asp:DropDownList>
                                                                                <tr id="row4">
                                                                                    <td nowrap>
                                                                                        <span class="lbl" id="priority_label" runat="server">Priority:&nbsp;</span>
                                                                                        <td nowrap>
                                                                                            <span class="stat" id="static_priority" runat="server"></span>
                                                                                            <asp:DropDownList ID="priority" runat="server">
                                                                                            </asp:DropDownList>
                                                                                            <tr id="row5">
                                                                                                <td nowrap>
                                                                                                    <span class="lbl" id="assigned_to_label" runat="server">Assigned to:&nbsp;</span>
                                                                                                    <td nowrap>
                                                                                                        <span class="stat" id="static_assigned_to" runat="server"></span>
                                                                                                        <asp:DropDownList ID="assigned_to" runat="server">
                                                                                                        </asp:DropDownList>
                                                                                                        &nbsp; <span runat="server" class="err" id="assigned_to_err"></span>
                                                                                                        <tr id="row6">
                                                                                                            <td nowrap>
                                                                                                                <span class="lbl" id="status_label" runat="server">Status:&nbsp;</span>
                                                                                                                <td nowrap>
                                                                                                                    <span class="stat" id="static_status" runat="server"></span>
                                                                                                                    <asp:DropDownList ID="status" runat="server">
                                                                                                                    </asp:DropDownList>
                                                                                                                    <%
                                                                                                                        if (btnet.Util.get_setting("ShowUserDefinedBugAttribute", "1") == "1")
                                                                                                                        {
                                                                                                                    %>
                                                                                                                    <tr id="row7">
                                                                                                                        <td nowrap>
                                                                                                                            <span class="lbl" id="udf_label" runat="server">
                                                                                                                                <% Response.Write(btnet.Util.get_setting("UserDefinedBugAttributeName", "YOUR ATTRIBUTE")); %>:&nbsp;</span>
                                                                                                                            <td nowrap>
                                                                                                                                <span class="stat" id="static_udf" runat="server"></span>
                                                                                                                                <asp:DropDownList ID="udf" runat="server">
                                                                                                                                </asp:DropDownList>
                                                                                                                                <%
                                                                                                                                    }

int minTextAreaSize = int.Parse(btnet.Util.get_setting("TextAreaThreshold", "100"));
int maxTextAreaRows = int.Parse(btnet.Util.get_setting("MaxTextAreaRows", "5"));

// Create the custom column INPUT elements
foreach (DataRow drcc in ds_custom_cols.Tables[0].Rows)
{
    string column_name = (string)drcc["name"];

    int field_permission_level = security.user.dict_custom_field_permission_level[column_name];
    if (field_permission_level == Security.PERMISSION_NONE)
    {
        continue;
    }

    string field_id = column_name.Replace(" ", "");

    Response.Write("\n<tr id=\"" + field_id + "_row\">");
    Response.Write("<td nowrap><span id=\"" + field_id + "_label\">");
    Response.Write(column_name);

    int permission_on_original = permission_level;

    if ((prev_project.Value != string.Empty)
    && (project.SelectedItem == null || project.SelectedItem.Value != prev_project.Value))
    {
        permission_on_original = fetch_permission_level(prev_project.Value);
    }

    if (permission_on_original == Security.PERMISSION_READONLY
    || permission_on_original == Security.PERMISSION_REPORTER)
    {
        Response.Write(":</span><td align=left width=600px>");
    }
    else
    {
        Response.Write(":</span><td align=left>");
    }

    //20040413 WWR - If a custom database field is over the defined character length, use a TextArea control
    int fieldLength = int.Parse(drcc["length"].ToString());
    string datatype = drcc["datatype"].ToString();

    if (datatype == "nvarchar" || datatype == "nchar")
    {
        fieldLength = fieldLength / 2;
    }

    string dropdown_type = Convert.ToString(drcc["dropdown type"]);

    if (permission_on_original == Security.PERMISSION_READONLY
    || field_permission_level == Security.PERMISSION_READONLY)
    {
        string text = hash_custom_cols[column_name];
        if (fieldLength > minTextAreaSize && !string.IsNullOrEmpty(text))
        {
            // more readable if there is a lot of text
            Response.Write("<div class='short_desc_static'  id=\"" + field_id + "_static\"><pre>");
            Response.Write(text);
            Response.Write("</pre></div>");
        }
        else
        {
            Response.Write("<span class='stat' id=\"" + field_id + "_static\">");
            if (dropdown_type == "users")
            {
                if (!string.IsNullOrEmpty(text))
                {
                    int view_only_user_id = Convert.ToInt32(text);
                    DataView dv_users = new DataView(dt_users);
                    foreach (DataRowView drv in dv_users)
                    {
                        if (view_only_user_id == (int)drv[0])
                        {
                            Response.Write(Convert.ToString(drv[1]));
                            break;
                        }
                    }
                }
            }
            else
            {
                Response.Write(text);
            }

            Response.Write("</span>");
        }
    }
    else
    {

        if (fieldLength > minTextAreaSize
        && dropdown_type != "normal"
        && dropdown_type != "users")
        {
            Response.Write("<textarea class='txt resizable'");
            Response.Write(" onkeydown=\"return count_chars('" + field_id + "'," + fieldLength + ")\" ");
            Response.Write(" onkeyup=\"return count_chars('" + field_id + "'," + fieldLength + ")\" ");
            Response.Write(" cols=\"" + minTextAreaSize + "\" rows=\"" + (((fieldLength / minTextAreaSize) > maxTextAreaRows) ? maxTextAreaRows : (fieldLength / minTextAreaSize)) + "\" ");
            Response.Write(" name=\"" + column_name + "\"");
            Response.Write(" id=\"" + field_id + "\" >");
            Response.Write(HttpUtility.HtmlEncode(hash_custom_cols[column_name]));
            Response.Write("</textarea><div class=smallnote id=\"" + field_id + "_cnt\">&nbsp;</div>");
        }
        else
        {
            string dropdown_vals = Convert.ToString(drcc["vals"]);

            if (dropdown_type != "" || dropdown_vals != "")
            {
                string selected_value = hash_custom_cols[column_name].Trim();

                Response.Write("<select ");

                Response.Write(" id=\"" + field_id + "\"");
                Response.Write(" name=\"" + column_name + "\"");
                Response.Write(">");

                if (dropdown_type != "users")
                {
                    string[] options = btnet.Util.split_dropdown_vals(dropdown_vals);
                    string decoded_selected_value = HttpUtility.HtmlDecode(selected_value);
                    for (int j = 0; j < options.Length; j++)
                    {
                        Response.Write("<option");
                        string decoded_option = HttpUtility.HtmlDecode(options[j]);
                        if (decoded_option == decoded_selected_value)
                        {
                            Response.Write(" selected ");
                        }
                        Response.Write(">");
                        Response.Write(decoded_option);
                        Response.Write("</option>");
                    }
                }
                else
                {
                    Response.Write("<option value=0>[not selected]</option>");

                    DataView dv_users = new DataView(dt_users);
                    foreach (DataRowView drv in dv_users)
                    {
                        string user_id = Convert.ToString(drv[0]);
                        string user_name = Convert.ToString(drv[1]);

                        Response.Write("<option value=");
                        Response.Write(user_id);

                        if (user_id == selected_value)
                        {
                            Response.Write(" selected ");
                        }
                        Response.Write(">");
                        Response.Write(user_name);
                        Response.Write("</option>");
                    }
                }
                Response.Write("</select>");
            }
            else
            {
                Response.Write("<input type=text onkeydown=\"mark_dirty()\" onkeyup=\"mark_dirty()\" ");

                // match the size of the text field to the size of the database field

                if (datatype.IndexOf("char") > -1)
                {
                    Response.Write(" size=" + Convert.ToString(fieldLength));
                    Response.Write(" maxlength=" + Convert.ToString(fieldLength));
                }

                Response.Write(" name=\"" + column_name + "\"");
                Response.Write(" id=\"" + field_id + "\"");
                Response.Write(" value=\"");
                Response.Write(hash_custom_cols[column_name]);

                if (datatype == "datetime")
                {
                    Response.Write("\" class='txt date'  >");
                    Response.Write("<a style=\"font-size: 8pt;\"href=\"javascript:show_calendar('"
                        + field_id
                        + "');\">[select]</a>");
                }
                else
                {
                    Response.Write("\" class='txt' >");
                }
            }
        }
    } // end if readonly or editable
} // end loop through custom fields

// create project custom dropdowns
if (project.SelectedItem != null
&& project.SelectedItem.Value != null
&& project.SelectedItem.Value != "0")
{
    sql = @"select
			isnull(pj_enable_custom_dropdown1,0) [pj_enable_custom_dropdown1],
			isnull(pj_enable_custom_dropdown2,0) [pj_enable_custom_dropdown2],
			isnull(pj_enable_custom_dropdown3,0) [pj_enable_custom_dropdown3],
			isnull(pj_custom_dropdown_label1,'') [pj_custom_dropdown_label1],
			isnull(pj_custom_dropdown_label2,'') [pj_custom_dropdown_label2],
			isnull(pj_custom_dropdown_label3,'') [pj_custom_dropdown_label3],
			isnull(pj_custom_dropdown_values1,'') [pj_custom_dropdown_values1],
			isnull(pj_custom_dropdown_values2,'') [pj_custom_dropdown_values2],
			isnull(pj_custom_dropdown_values3,'') [pj_custom_dropdown_values3]
			from projects where pj_id = $pj";

    sql = sql.Replace("$pj", project.SelectedItem.Value);

    DataRow project_dr = btnet.DbUtil.get_datarow(sql);


    if (project_dr != null)
    {
        for (int i = 1; i < 4; i++)
        {
            if ((int)project_dr["pj_enable_custom_dropdown" + Convert.ToString(i)] == 1)
            {
                // GC: 20-Feb-08: Modified to add an ID to each custom row for CSS customisation
                Response.Write("\n<tr id=\"pcdrow" + Convert.ToString(i) + "\"><td nowrap>");

                Response.Write("<span id=label_pcd" + Convert.ToString(i) + ">");
                Response.Write(project_dr["pj_custom_dropdown_label" + Convert.ToString(i)]);
                Response.Write("</span>");
                // End GC
                Response.Write("<td nowrap>");


                int permission_on_original = permission_level;
                if ((prev_project.Value != string.Empty) && (project.SelectedItem.Value != prev_project.Value))
                {
                    permission_on_original = fetch_permission_level(prev_project.Value);
                }

                if (permission_on_original == Security.PERMISSION_READONLY
                || permission_on_original == Security.PERMISSION_REPORTER)
                {
                    // GC: 20-Feb-08: Modified to add an ID to the SPAN as well for easier CSS customisation
                    //Response.Write ("<span class="stat">");
                    Response.Write("<span class='stat' id=span_pcd" + Convert.ToString(i) + ">");

                    if (IsPostBack)
                    {
                        string val = HttpUtility.HtmlEncode(Request["pcd" + Convert.ToString(i)]);

                        Response.Write(val);
                        Response.Write("</span>");

                        Response.Write("<input type=hidden name=pcd"
                            + Convert.ToString(i)
                            + " value=\""
                            + val
                            + "\">");

                    }
                    else
                    {
                        if (id != 0)
                        {
                            string val = (string)dr["bg_project_custom_dropdown_value" + Convert.ToString(i)];
                            Response.Write(val);
                            Response.Write("</span>");

                            Response.Write("<input type=hidden name=pcd"
                                + Convert.ToString(i)
                                + " value=\""
                                + val
                                + "\">");

                        }
                        else
                        {
                            Response.Write("</span>");
                        }
                    }


                }
                else
                {

                    // create a hidden area to carry the label

                    Response.Write("<input type=hidden");
                    Response.Write(" name=label_pcd" + Convert.ToString(i));
                    Response.Write(" value=\"");
                    Response.Write(project_dr["pj_custom_dropdown_label" + Convert.ToString(i)]);
                    Response.Write("\">");

                    // create a dropdown

                    Response.Write("<select");
                    // GC: 20-Feb-08: Added an ID as well for easier CSS customisation
                    Response.Write(" name=pcd" + Convert.ToString(i));
                    Response.Write(" id=pcd" + Convert.ToString(i) + ">");
                    string[] options = btnet.Util.split_dropdown_vals(
                        (string)project_dr["pj_custom_dropdown_values" + Convert.ToString(i)]);

                    string selected_value = "";

                    if (IsPostBack)
                    {
                        selected_value = Request["pcd" + Convert.ToString(i)];
                    }
                    else
                    {
                        // first time viewing existing
                        if (id != 0)
                        {
                            selected_value = (string)dr["bg_project_custom_dropdown_value" + Convert.ToString(i)];
                        }
                    }

                    for (int j = 0; j < options.Length; j++)
                    {
                        Response.Write("<option value=\"" + options[j] + "\"");

                        //if (options[j] == selected_value)
                        if (HttpUtility.HtmlDecode(options[j]) == selected_value)
                        {
                            Response.Write(" selected ");
                        }
                        Response.Write(">");
                        Response.Write(options[j]);
                    }

                    Response.Write("</select>");
                }
            }
        }
    } // if result set not null
}

                                                                                                                                %>
                            </table>
                            <table border="0" cellpadding="0" cellspacing="3" width="98%">
                                <tr>
                                    <td nowrap>
                                        &nbsp; <span id="comment_label" runat="server">Comment:</span> <span class="smallnote"
                                            style="margin-left: 170px">
                                            <% 
                                                if (permission_level != Security.PERMISSION_READONLY)
                                                {

                                                    Response.Write("Entering \""
                                                        + btnet.Util.get_setting("BugLinkMarker", "bugid#")
                                                        + "999\" in comment creates link to id 999");
                                                } 
                                            %>
                                        </span>
                                        <br>
                                        <textarea id="comment" rows="5" cols="100" runat="server" class="txt resizable2"
                                            onkeydown="mark_dirty()" onkeyup="mark_dirty()"></textarea>
                                        <tr>
                                            <td nowrap>
                                                <asp:CheckBox runat="server" class="cb" ID="internal_only" />
                                                <span runat="server" id="internal_only_label">Comment visible to internal users only</span>
                                                <tr>
                                                    <td nowrap align="left">
                                                        <span runat="server" class="err" id="custom_field_msg">&nbsp;</span> <span runat="server"
                                                            class="err" id="custom_validation_err_msg">&nbsp;</span> <span runat="server" class="err"
                                                                id="msg">&nbsp;</span>
                                                        <tr>
                                                            <td nowrap align="center">
                                                                <input runat="server" class="btn" type="submit" id="sub" onclick="disable_me()" value="Update"
                                                                    onserverclick="on_update">
                            </table>
                            <input type="hidden" id="new_id" runat="server" value="0">
                            <input type="hidden" id="prev_short_desc" runat="server">
                            <input type="hidden" id="prev_tags" runat="server">
                            <input type="hidden" id="prev_project" runat="server">
                            <input type="hidden" id="prev_project_name" runat="server">
                            <input type="hidden" id="prev_org" runat="server">
                            <input type="hidden" id="prev_org_name" runat="server">
                            <input type="hidden" id="prev_category" runat="server">
                            <input type="hidden" id="prev_priority" runat="server">
                            <input type="hidden" id="prev_assigned_to" runat="server">
                            <input type="hidden" id="prev_assigned_to_username" runat="server">
                            <input type="hidden" id="prev_status" runat="server">
                            <input type="hidden" id="prev_udf" runat="server">
                            <input type="hidden" id="prev_pcd1" runat="server">
                            <input type="hidden" id="prev_pcd2" runat="server">
                            <input type="hidden" id="prev_pcd3" runat="server">
                            <input type="hidden" id="snapshot_timestamp" runat="server">
                            <input type="hidden" id="clone_ignore_bugid" runat="server" value="0">
                            <%

                                // create the "Prev" fields for the custom columns so that we
                                // can create an audit trail of their changes.

                                foreach (string column_name in hash_custom_cols.Keys)
                                {
                                    Response.Write("<input type=hidden name=\"prev_");
                                    Response.Write(column_name);
                                    Response.Write("\"");

                                    // output a date field according to the specified format
                                    Response.Write(" value=\"");
                                    //modified by CJU on jan 9 2008
                                    Response.Write(HttpUtility.HtmlEncode(hash_custom_cols[column_name]));
                                    //modified by CJU on jan 9 2008
                                    Response.Write("\">\n");
                                }

                                if (id != 0)
                                {
                                    ds_posts = PrintBug.get_bug_posts(id, security.user.external_user, history_inline);
                                    string link_marker = Util.get_setting("BugLinkMarker", "bugid#");
                                    Regex reLinkMarker = new Regex(link_marker + "([0-9]+)");
                                    SortedDictionary<int, int> dict_linked_bugs = new SortedDictionary<int, int>();

                                    // fish out bug links
                                    foreach (DataRow dr_post in ds_posts.Tables[0].Rows)
                                    {
                                        if ((string)dr_post["bp_type"] == "comment")
                                        {
                                            MatchCollection match_collection = reLinkMarker.Matches((string)dr_post["bp_comment"]);

                                            foreach (Match match in match_collection)
                                            {
                                                int other_bugid = Convert.ToInt32(match.Groups[1].ToString());
                                                if (other_bugid != id)
                                                {
                                                    dict_linked_bugs[other_bugid] = 1;
                                                }
                                            }
                                        }
                                    }

                                    if (dict_linked_bugs.Count > 0)
                                    {
                                        Response.Write("Linked to:");
                                        foreach (int int_other_bugid in dict_linked_bugs.Keys)
                                        {
                                            string string_other_bugid = Convert.ToString(int_other_bugid);

                                            Response.Write("&nbsp;<a href=edit_bug.aspx?id=");
                                            Response.Write(string_other_bugid);
                                            Response.Write(">");
                                            Response.Write(string_other_bugid);
                                            Response.Write("</a>");
                                        }
                                    }
                                }
    
                            %>
                            </form>
                        </div>
                        <!-- bug form div -->
        </table>
        <br>
        <span id="toggle_images" runat="server"></span>&nbsp;&nbsp;&nbsp;&nbsp; <span id="toggle_history"
            runat="server"></span>
        <br>
        <br>
        <div id="posts">
            <%
                // COMMENTS
                if (id != 0)
                {
                    PrintBug.write_posts(
                        ds_posts,
                        Response,
                        id,
                        permission_level,
                        true, // write links
                        images_inline,
                        history_inline,
                        true, // internal_posts
                        security.user);
                }

            %>
        </div>
    </div>
    <asp:Literal ID="custom_footer_label" runat="server"></asp:Literal></body>
</html>
